#ifndef AVDELLUXER_H
#define AVDELLUXER_H
#include <atomic>
#include <QString>
#include <thread>
#include <memory>//智能指针
#include <functional>

struct AVFormatContext;
class AVDelluxer
{
public:
    AVDelluxer();
    bool Open(const QString path);
    using StreamCallback = std::function<void(bool)>;
    inline void SetStreamCallback(const StreamCallback& cb){streamCb_ = cb;};
protected:
    void Close();
    void FetchStream(const QString path);
    bool FetchStreamInfo(const QString path);
    static int InterruptFountion(void* arg);//通过这个函数返回值停止
private:
    int videoIndex = -1;
    int AudioIndex = -1;
    std::atomic_bool quit_;
    AVFormatContext* pFormatCtx_ = nullptr;
    std::unique_ptr<std::thread> readThread_ =nullptr;
    StreamCallback streamCb_ = [](bool){};


};

#endif // AVDELLUXER_H
